


package com.gc.server.controller;
import com.yf.request.SearchParam;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import com.gc.server.vo.DayOffVo;
import com.gc.server.service.DayOffService;
import com.yf.response.R;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
            
/**
 * 节假日Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Thu Oct 22 09:16:32 CST 2020
 */
@RestController
@RequestMapping("/day/off")
public class DayOffController {
    @Autowired
    private DayOffService dayOffService;

    /**
     * 列表节假日
     */
    @SysLog("查看节假日")
    @RequestMapping("/list")
    @RequiresPermissions("day:off:list")
    public R list(@RequestBody SearchParam<DayOffVo> params) {
        PageHelper.startPage(params.getPage(), params.getLimit()).setOrderBy(params.getOrder());
        List<DayOffVo> list = dayOffService.findVo(params.getEntity());
        return R.ok(new PageInfo(list));
    }

    /**
 * 下载订单
 */
    @SysLog("下载订单")
    @RequestMapping("/down")
    @RequiresPermissions("day:off:list")
    public void down(@RequestBody SearchParam<DayOffVo> params, HttpServletResponse response) {
        List<DayOffVo> list = dayOffService.findVo(params.getEntity());
            dayOffService.downLoad(response, list);
    }


    /**
     * 查看节假日
     */
    @SysLog("查看节假日")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("day:off:info")
    public R info(@PathVariable("id") Long id) {
            DayOffVo vo = dayOffService.getVo(id);

        return R.ok(vo);
    }

    /**
     * 保存节假日
     */
    @SysLog("保存节假日")
    @RequestMapping("/save")
    @RequiresPermissions("day:off:save")
    public R save(@RequestBody DayOffVo vo) {
            dayOffService.saveVo(vo);
        return R.ok(vo);
    }

    /**
     * 修改节假日
     */
    @SysLog("修改节假日")
    @RequestMapping("/update")
    @RequiresPermissions("day:off:update")
    public R update(@RequestBody DayOffVo vo) {
            dayOffService.updateVo(vo);

        return R.ok(vo);
    }

    /**
     * 删除节假日
     */
    @SysLog("删除节假日")
    @RequestMapping("/delete")
    @RequiresPermissions("day:off:delete")
    public R delete(Long[]ids) {
            dayOffService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有节假日
     */
    @SysLog("所有节假日")
    @RequestMapping("/all")
    public R all(String order) {
        PageHelper.orderBy(order!=null ? order : "id desc");
        List<DayOffVo> list = dayOffService.findVo(null);
        return R.ok(list);
    }

    /**
     * 所有enums
     */
    @SysLog("所有enums")
    @RequestMapping("/dmz/options")
    public R options() {
        HashMap<String,Object> options = new HashMap();
                                                                            return R.ok(options);
    }





    /***********自定义开始***********/
}
